package org.dx.oho.book.one.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;

/**
 * create by duanx 2021/5/24
 *@description： todo
 *@classname: MyInterceptor
 *@author: duanx
 *@date: 2021/5/24 23:33
 **/
public class MyInterceptor implements Interceptor{
    private Logger logger = LoggerFactory.getLogger(MyInterceptor.class);
    @Override
    public boolean before(Object proxy, Object target, Method method, Object[] args) {
        logger.info("反射方法之前的逻辑，如逻辑成立返回true");
        return !"李二".equals(args[0]);
    }

    @Override
    public void around(Object proxy, Object target, Method method, Object[] args) {
        logger.info("取代被代理的方法");
    }

    @Override
    public void after(Object proxy, Object target, Method method, Object[] args) {
        logger.info("反射方法之后的逻辑");
    }
}
